実験計画法まとめ

ライブラリの読み込み

library(AlgDesign)
library(plotly)
## Loading required package: ggplot2
## Warning: replacing previous import 'vctrs::data_frame' by 'tibble::data_frame'
## when loading 'dplyr'
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

直交表

  • 3水準4変数の場合、\(3^4=81\)個の条件が生成される。
## 3変数の場合は
dat <- gen.factorial(3, 4, varNames = c("A", "B", "C", "D"))
dat

配合計画

3変数で生成

dat <- gen.mixture(4, c("A","B","C"))
dat
cor(dat)
##      A    B    C
## A  1.0 -0.5 -0.5
## B -0.5  1.0 -0.5
## C -0.5 -0.5  1.0

3変数で可視化

plot_ly(dat, a = ~A, b = ~B, c = ~C, marker=list(color="black", size=20), type = "scatterternary")
## No scatterternary mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode

Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.